#include <iostream>

using namespace std;

const int N = 3010, MOD = 2333;

int n, m;
int a[N][N];
int dp[N][N];

int main()
{
	scanf("%d%d", &n, &m);

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			scanf("%d", &a[i][j]);

	// 初始dp数组 其他位置为0
	dp[n][0] = 1;

	for (int i = n; i >= 1; i--) // 从下往上填充
	{
		for (int j = 1; j <= m; j++) // 从左往右填充
		{
			if (a[i][j] == 0)
			{
				dp[i][j] = (dp[i][j - 1] + dp[i + 1][j]) % MOD;
			}
		}
	}


	cout << dp[1][m] << endl;

	return 0;
}